/**
 * Created by ptt on 2016/5/27/0027.
 */
define(["./../navigation/dataHandle.js", "../maintools/Controller.js"], function (handle, Controller) {
    //initial searchbox has bug for global value jQuery
    Controller = Controller.Controller;
    var Legend = Controller.create({
        init: function (element) {
            this.el = jQuery(element);
            this.refreshElements();
            this.delegateEvents();
            Message_bone.on("legendShow", this.proxy(function (e, data){
                this.show(e, data);
            }));
            Message_bone.on("legendHide", this.proxy(function (){
                this.hide();
            }));
        },
        show: function (e, data) {
            this.render(data);
            var elem = this.el;
            elem.animate({
                bottom: "0"
            });
        },
        hide: function (e) {
            var elem = this.el;
            elem.animate({
                bottom: "-50px"
            });
        },
        template: "#tlegend"
    });
    var legendTrigger = new Legend("#legend");
    legendTrigger.render([
        {
            color: "red",
            text: "fff"
        },
        {
            color: "green",
            text: "xxx"
        }
    ]);
    legendTrigger.hide();
    return {
        legendController: legendTrigger
    };
});